package RMI;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

public final class ClienteManager {

    private static final String CONFIGURATION_FILE = "Servidor.properties";
    private static Map parameters;

    static {
        try {
        /* Lee el archivo de propiedades (si es que existe) */
            Class configurationParametersManagerClass = ClienteManager.class;
            ClassLoader classLoader = configurationParametersManagerClass.getClassLoader();
            InputStream inputStream = classLoader.getResourceAsStream(CONFIGURATION_FILE);
            Properties properties = new Properties();
            properties.load(inputStream);
            inputStream.close();
            HashMap hashMap = new HashMap(properties);
            parameters = hashMap;
        } catch (IOException e) {
            System.out.println("ERROR: " + e.toString());
        }
    }

    public static String getParameter(String name) throws MissingConfigurationParameterException {
         String value = (String) parameters.get(name);
         if (value == null) {
            throw new MissingConfigurationParameterException(name);
         }
         return value;
    }
}
